.org 0xE63B0 ; Defense Increase (Tag & Transport)

Defense_Increase_Tag_Transport:

	PUSH 	{R4-R7, LR}
	SUB		SP, SP, 4
	
	MOV		R6, 0								; Defense bonus = 0
	
;-------------------------------------------------------------------------------

	LDR 	R4, [Defense_Increase_Tag_Transport_1]
	LDR 	R3, [Defense_Increase_Tag_Transport_2]
	LDR 	R5, [R4, 0]
	LDR 	R4, [R3, 0]
	
	MOV 	R3, 0x98	
	ADD		R4, R5, R4, LSL 2
	MUL 	R5, R0, R3
	LDR 	R4, [R4, 0x48]	
	MOV		R7, R2
	ADD 	R0, R4, 0x5000
	LDR 	R0, [R0, 0xA58]
	MOV		R4, R1, LSL 4
	ADD		R0, R0, R5
	ADD 	R0, R0, 0x74
	ADD		R0, R0, R1, LSL 4

	MOV		R1, CO_Bodyguard					; Skill: Bodyguard		
	
	BL 		Check_Skills_Equipped				; Check the Skill is equipped	
	CMP 	R0, 0								; Does CO use that skill?
	ADDNE 	R6, R6, Stats_Bodyguard				; If CO use skill, Partner has defense	

;-------------------------------------------------------------------------------
	
	MOV		R0, R7								; R0 = Unit
	
	BL		Check_Unit_Type
	
	CMP		R0, Unit_Transport					; Is unit a Transport?
	BNE		Unit_Not_Transport
	
;-------------------------------------------------------------------------------
		
	BL		Skill_Setup_Type_Defense_Transport
		
	MOV 	R1, Rank_APC_Guard					; Rank: APC Guard
	
	BL 		Check_Skills_Equipped				; Check the Skill is equipped	
	CMP 	R0, 0								; Does CO use that skill?
	ADDNE 	R6, R6, Stats_APC_Guard				; If CO use skill, more Transport defense

;-------------------------------------------------------------------------------
	
Unit_Not_Transport:
		
	MOV		R0, R6								; Total defense bonus
	
	ADD		SP, SP, 4	
	POP 	{R4-R7, LR}	
	BX 		LR

;-------------------------------------------------------------------------------		

	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
		
;-------------------------------------------------------------------------------	

Defense_Increase_Tag_Transport_1:
	.dw Reg1_Skill
	
Defense_Increase_Tag_Transport_2:
	.dw Reg2_Skill



